<?php
	namespace Common\Logic;
	use Common\Model\OrderCommentModel;
	class OrderCommentLogic extends OrderCommentModel{
		/*
		* Function:		getOrderCommentList
		* Description:	订单评论列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getOrderCommentList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getOrderCommentFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getOrderCommentFilter
		* Description:	订单评论列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getOrderCommentFilter($filter = ''){
			$conditon = array();
			if(empty($filter['flag'])){
			    $conditon['status'] = 1;
			}
			if(!empty($filter['goods_id'])){
				$conditon['goods_id'] = $filter['goods_id'];
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getOrderCommentCount
		* Description:	订单评论列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getOrderCommentCount($filter = ''){
			$conditon = $this->getOrderCommentFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addOrderComment
		* Description:	增加订单评论
		* @param:		$data array 增加的数组
		*/
		public function addOrderComment($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getOrderCommentInfo
		* Description:	获取订单评论信息 by row
		* @param:		$id int ID
		*/
		public function getOrderCommentInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateOrderComment
		* Description:	更新订单评论
		* @param:		$data array 更新的数组
		*/
		public function updateOrderComment($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteOrderComment
		* Description:	删除订单评论
		* @param:		$id int ID
		*/
		public function deleteOrderComment($id){
			return $this->where(array('id'=>$id))->delete();
		}
		
		/*
		* Function:		getOrderCommentAllList
		* Description:	订单评论列表
		*/
		public function getOrderCommentAllList(){
			return $this->where(array('status'=>1))->select();
		}

		/*
		* Function:		getOrderCommentAll
		* Description:	订单评论列表-根据商品id
		*/
		public function getOrderCommentAll($goods_id = '',$page=1,$pageSize=20){
			$conditon = [];
			$conditon['status'] = 1;
			if(!empty($goods_id)){
				$conditon['goods_id'] = $goods_id;
			}
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}

		/*
		* Function:		getOrderCommentCounts
		* Description:	订单评论列表-根据商品id
		*/
		public function getOrderCommentCounts($goods_id = ''){
			$conditon = [];
			$conditon['status'] = 1;
			if(!empty($goods_id)){
				$conditon['goods_id'] = $goods_id;
			}
			return $this->where($conditon)->count();
		}
	}
?>